package es.uem.listaactividades;

import java.io.IOException;

import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;


public class PruebaSoundPool extends Activity  {
	String TAG ="PruebaSoundPool";
	SoundPool soundPool;
	int cristalId = -1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_pruebasoundpool);
		
		
		setVolumeControlStream(AudioManager.STREAM_MUSIC);
		soundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0);
		
		try {
			AssetManager assetManager = getAssets();
			AssetFileDescriptor descriptor = assetManager
					.openFd("cristal.mp3");
			cristalId = soundPool.load(descriptor, 1);
		} catch (IOException e) {
			Log.d(TAG,"No se pudo cargar el sonido de la" +
					    " carpeta asset ");
			Log.d(TAG,e.getMessage());
		}
	}
	
	public void sound(View view) {
		
			if (cristalId != -1) {
				soundPool.play(cristalId, 1, 1, 0, 0, 1);
			}		
	
	}
	
	public void play(View view) {
		
		
		}		
		
	public void stop(View view) {
			
		
			}	

}
	


